package com.dmlll.service.impl;

import com.dmlll.VO.*;
import com.dmlll.domain.DrugMessage;
import com.dmlll.domain.Provider;
import com.dmlll.mapper.DrugCategoryMapper;
import com.dmlll.mapper.DrugMessageMapper;
import com.dmlll.mapper.ProviderDrugCatalogControlMapper;
import com.dmlll.mapper.ProviderMapper;
import com.dmlll.service.ProviderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author dmLll
 * @since 2021-04-02
 */
@Service
public class ProviderServiceImpl extends ServiceImpl<ProviderMapper, Provider> implements ProviderService {

    @Autowired
    private ProviderMapper providerMapper;

    @Autowired
    private DrugMessageMapper drugMessageMapper;

    @Autowired
    private ProviderDrugCatalogControlMapper providerDrugCatalogControlMapper;

    @Autowired
    private DrugCategoryMapper drugCategoryMapper;

    @Override
    public PageInfo<DeliverGoodsVO> findAll(Integer pageNum, Integer pageSize, DeliverGoodDTO deliverGoodDTO,Integer id) {
        PageHelper.startPage(pageNum,pageSize);
        List<DeliverGoodsVO> list=providerMapper.selectAll(deliverGoodDTO,id);
        PageInfo<DeliverGoodsVO> pageInfo=new PageInfo<>(list);
        return pageInfo;

    }
    //勾选导出
    @Override
    public List<DeliverGoodsVO> findByIdList(Integer[] idList){
        return providerMapper.selectByidList(idList);
    }
    //发货
    @Override
    public int deleteByinList(Integer[] idList){
        return providerMapper.deleteByIdList(idList);
    }
    //无法供货
    @Override
    public int deleteWuinList(Integer[] idList){
        return providerMapper.deleteWuIdList(idList);
    }
    //导入发货
    @Override
    public int deletdaoru(DeliverGoodsVO deliverGoodsVO){
        return providerMapper.selectdaoru(deliverGoodsVO);
    }


    @Override
    //商品管理信息查询
    public PageInfo<DrugMessageVOgcl> findguanli(Integer pageNum, Integer pageSize, DrugMessageDTOgcl drugMessageDTOgcl,Integer id){
        PageHelper.startPage(pageNum,pageSize);
        List<DrugMessageVOgcl> list=providerMapper.selectguanli(drugMessageDTOgcl,id);
        PageInfo<DrugMessageVOgcl> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }
    //取消供货
    @Override
    public int deleteGongidList(Integer[] idList){
        return providerDrugCatalogControlMapper.deleteGongidList(idList);
    }
    //确认供货页面查询
    @Override
    public PageInfo<DrugMessageVOgcl> findyao(Integer pageNum, Integer pageSize, DrugMessageDTOgcl drugMessageDTOgcl,Integer id){
        PageHelper.startPage(pageNum,pageSize);
        List<DrugMessageVOgcl> list=providerMapper.selectyao(drugMessageDTOgcl,id);
        PageInfo<DrugMessageVOgcl> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }
    //确认供货
    @Override
    public int insertQueren(@Param("idList") List<Integer[]> idList){
        return providerDrugCatalogControlMapper.insertQueren(idList);
    }
    //供货商商品维护页面查询
    @Override
    public PageInfo<Drug_maintenanceVOgcl> findmaintain(Integer pageNum, Integer pageSize,DrugmaintenanceDTOgcl drugmaintenanceDTOgcl){
        PageHelper.startPage(pageNum,pageSize);
        List<Drug_maintenanceVOgcl> list=providerMapper.selectMaintain(drugmaintenanceDTOgcl);
        PageInfo<Drug_maintenanceVOgcl> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }
    //供货商商品维护页面查询导出
    @Override
    public List<Drug_maintenanceVOgcl> findAllExcel(){
        return providerMapper.selectAllExcel();
    }
    //
    //供货商商品维护页面修改反显
    @Override
    public List<DrugMessage> findAllxiu(Integer id){
        return providerMapper.selectAllxiu(id);
    }
    //查询所有供应商的名字
    @Override
    public List<Provider> findgongName(){
        return providerMapper.selectgongName();
    }
    //修改
    @Override
    public int updateXiugai(DrugMessage drugMessage){
        return providerMapper.updateXiugai(drugMessage);
    }
    //根据id查询药品的详细信息
    @Override
    public List<ParticularVOgcl> findXiangxi(Integer id){
        return providerMapper.selectXiangxi(id);
    }

    //供货商审核
    @Override
    public  PageInfo<Drug_maintenanceVOgcl> findGongshen(Integer pageNum, Integer pageSize,DrugmaintenanceDTOgcl drugmaintenanceDTOgcl){
        PageHelper.startPage(pageNum,pageSize);
        List<Drug_maintenanceVOgcl> list=providerMapper.selectGongsen(drugmaintenanceDTOgcl);
        PageInfo<Drug_maintenanceVOgcl> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }
    //允许上架
    @Override
    public int  insertGongtong(Integer[] idList){
        return providerMapper.deleteGongtong(idList);
    }
    //药品品目维护查询
    @Override
    public PageInfo<DrugMessageVOgcl> findweihuyao(Integer pageNum, Integer pageSize, DrugMessageDTOgcl drugMessageDTOgcl){
        PageHelper.startPage(pageNum,pageSize);
        List<DrugMessageVOgcl> list=providerMapper.selectweihuyao(drugMessageDTOgcl);
        PageInfo<DrugMessageVOgcl> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }
    //药品品目修改
    @Override
    public int updateGuanxiu(DrugMessageVOgcl drugMessageVOgcl){
        return providerMapper.updateGuanXiu(drugMessageVOgcl);
    }
    //删除
    @Override
    public int deleteDrugidList(Integer id){
        return drugMessageMapper.deleteDrugidList(id);
    }
    //单条添加
    @Override
    public int insettian(DrugMessage drugMessage){
        return providerMapper.insertdrug(drugMessage);
    }
    //根据药品id导出药品数据
    @Override
    public List<DrugMessageVOgcl> findBydrug(Integer[] idList){
        return providerMapper.selectBydrug(idList);
    }
    //根据药品类别名查询出药品id
    public int category(String category){
        return drugCategoryMapper.category(category);

    }


}
